package com.shoulder.authorizationserver.rsa;

import com.shoulder.core.utils.IdUtils;

import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.time.Instant;

public class RsaKeyPair {

    private final String id;

    private final Instant created;

    private final RSAPublicKey publicKey;

    private final RSAPrivateKey privateKey;

    public RsaKeyPair(RSAPublicKey publicKey, RSAPrivateKey privateKey) {
        this(new IdUtils(1, 1).nextId() + "", Instant.now(), publicKey, privateKey);
    }

    public RsaKeyPair(Instant created, RSAPublicKey publicKey, RSAPrivateKey privateKey) {
        this(new IdUtils(1, 1).nextId() + "", created, publicKey, privateKey);
    }

    public RsaKeyPair(String id, Instant created, RSAPublicKey publicKey, RSAPrivateKey privateKey) {
        this.id = id;
        this.created = created;
        this.publicKey = publicKey;
        this.privateKey = privateKey;
    }

    public String getId() {
        return id;
    }

    public Instant getCreated() {
        return created;
    }

    public RSAPublicKey getPublicKey() {
        return publicKey;
    }

    public RSAPrivateKey getPrivateKey() {
        return privateKey;
    }
}